
$(function () {

    $("#top").load("top.html");
    $("#left").load("department_left.html",function () {
        menuActive(2,0)
    });

    //初始化学院下拉列表
    requests.getReq(urls.getCollege,'',function (data) {
        if(data.status == 1){
            var collegeOpts = '';
            var list = data.data;
            for(var key in list){
                collegeOpts += '<option value="'+key+'">'+list[key]+'</option>>';
            }
            $("#collegeSel").append(collegeOpts);

        }else{
            showTip('服务器异常');
        }
    },function () {
        showTip('服务器异常');
    })


    //点击添加
    $("#add_post span").click(function () {
        var addParam = {
            "collegeId": $("#collegeSel").val(),
            "postCount": $("#postNum").val(),
            "postLevel": $("#postLevel").val(),
            "publisher": $("#publisher").val(),
            "userId": sessionStorage.getItem('userId')
        }
        for(var key in addParam){
            if(!$.trim(addParam[key])){
                showTip('请完善信息后提交');
                return;
            }
        }
        requests.postReq(urls.addTeachPost,JSON.stringify(addParam),
            function (data) {
                if(data.status == 1){
                    showTip('岗位级别添加成功',function () {
                        window.location.reload();
                    })
                }else{
                    showTip(data.message);
                }
            }
        )
    })

})